package cn.edu.scau.cmi.chenyuesong.adapter;
import java.util.ArrayList;
import java.util.List;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class myController {
	@FXML
	private Button btn_c,btn_o;
	@FXML
	private TextArea text_ca,text_oa;
	@FXML
	private TextField text_cf1,text_cf2,text_of1,text_of2;
	
	List<Student> students = new ArrayList<Student>();
	public void eventButton_c(){
        String name = text_cf1.getText();
        String num_s = text_cf2.getText();
        if(!name.equals("")&&!num_s.equals("")) {
        	Integer num = Integer.valueOf(num_s);
        	Student student = new Student(name, num);
        	students.add(student);
        	ClassAdapter classAdapter = new ClassAdapter();
        	classAdapter.SortStuList(students);
        	text_ca.clear();
        	for(int i=0;i<students.size();i++) {
        		text_ca.appendText(students.get(i).num+"  "+students.get(i).name+"\n");
        	}
        }
    }
	public void eventButton_o(){
        String name = text_of1.getText();
        String num_s = text_of2.getText();
        if(!name.equals("")&&!num_s.equals("")) {
        	Integer num = Integer.valueOf(num_s);
        	Student student = new Student(name, num);
        	students.add(student);
        	ObjectAdapter objectAdapter = new ObjectAdapter();
        	objectAdapter.SortStuList(students);
        	text_oa.clear();
        	for(int i=0;i<students.size();i++) {
        		text_oa.appendText(students.get(i).num+"  "+students.get(i).name+"\n");
        	}
        }
    }
}
